package edu.jd.movieplatform.user.feedback.impl;

import edu.jd.movieplatform.common.Utils;
import edu.jd.movieplatform.user.feedback.FeedbackDto;
import edu.jd.movieplatform.user.feedback.FeedbackService;
import edu.jd.movieplatform.user.feedback.dao.FeedbackDao;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

/**
 * @descriptions:
 * @data: 2021/7/10 16:45
 */
@Service
@Transactional
public class FeedbackServiceImpl implements FeedbackService {
    @Resource
    private FeedbackDao dao;

    @Override
    public boolean CreateFeedback(FeedbackDto dto) {
        dto.setFeedback_state(false);
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
        dto.setFeedback_time(df.format(new Date()));// new Date()为获取当前系统时间
        return dao.createFeedback(dto);
    }

    @Override
    public Map<String, Object> findFeedbackList(FeedbackDto dto) {
        return  Utils.getPage(dto, () -> dao.findFeedbackList(dto));
    }
}
